package com.disease.chronic.Controller;

import com.disease.chronic.Global.Result;
import com.disease.chronic.Service.DeviceService;
import com.disease.chronic.pojo.Device;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/device")
public class DeviceController {

    @Autowired
    DeviceService deviceService;

    @GetMapping("/get")
    public @ResponseBody Result getDevicesByUsername(@RequestParam("username")String username){
        return deviceService.getDevices(username);
    }
    @PostMapping("/add")
    public @ResponseBody Result addDevice(@RequestBody  Device device){
        return deviceService.addDevice(device.getDeviceId(), device.getUsername());
    }
}
